home *** CD-ROM | disk | FTP | other *** search
- { textout.pas -- Text Output Methods }
-
- program TextOutMethods;
-
- uses WinTypes, WinProcs, WObjects, Strings;
-
- type
-
- TextApplication = object(TApplication)
- procedure InitMainWindow; virtual;
- end;
-
- PTextWindow = ^TextWindow;
- TextWindow = object(TWindow)
- constructor Init(AParent: PWindowsObject; ATitle: PChar);
- procedure Paint(PaintDC: HDC; var PaintInfo: TPaintStruct);
- virtual;
- end;
-
- { TextApplication }
-
- {- Initialize the application's window }
- procedure TextApplication.InitMainWindow;
- begin
- MainWindow := New(PTextWindow, Init(nil, 'Text Output Methods'))
- end;
-
- { TextWindow }
-
- {- Initialize the application's window object }
- constructor TextWindow.Init(AParent: PWindowsObject; ATitle: PChar);
- begin
- TWindow.Init(AParent, ATitle);
- with Attr do
- begin
- X := 20; Y := 20; W := 300; H := 300
- end
- end;
-
- {- Paint text in window }
- procedure TextWindow.Paint(PaintDC: HDC; var PaintInfo:
- TPaintStruct);
- const
- SConst = 'A constant string';
- var
- S: String;
- C: Array[ 0 .. 255 ] of Char;
- begin
-
- {- Method 1: Display literal string }
- TextOut(PaintDC, 10, 10, 'A literal string', 16);
-
- {- Method 2: Display Pascal string variable }
- S := 'A Pascal string variable';
- TextOut(PaintDC, 10, 50, @S[1], Length(S));
-
- {- Method 3: Display C-style char array }
- S := 'A C-style char array';
- StrPCopy(@C, S);
- TextOut(PaintDC, 10, 90, C, StrLen(C));
-
- {- Method 4: Display string constant }
- TextOut(PaintDC, 10, 130, SConst, Length(SConst));
-
- end;
-
- var
-
- TextApp: TextApplication;
-
- begin
- TextApp.Init('TextApp');
- TextApp.Run;
- TextApp.Done
- end.
-
-
- {--------------------------------------------------------------
- Copyright (c) 1991 by Tom Swan. All rights reserved.
- Revision 1.00 Date: 1/11/1991
- ---------------------------------------------------------------}
-
-